package com.example.test.启动线程.线程变量共享;

public class Demo extends Thread {

    public static final InheritableThreadLocal<String> inheritableThreadLocal = new InheritableThreadLocal();

    @Override
    public void run() {
        inheritableThreadLocal.set("我想学习");
        Task task = new Task();
        task.start();
    }

    public static void main(String[] args) {
        Demo demo = new Demo();
        demo.start();
    }
}

class Task extends Thread {

    @Override
    public void run() {
        System.out.println(Demo.inheritableThreadLocal.get());
    }
}